package 反射.T10;

import java.lang.reflect.Field;

public class T10 {

    public static void main(String[] args) throws IllegalAccessException, InstantiationException, NoSuchFieldException {

        Class<Student> aClass = Student.class;
        Student s = aClass.newInstance();
        Field name = aClass.getDeclaredField("name");
        Field age = aClass.getDeclaredField("age");
        name.setAccessible(true);
        age.setAccessible(true);
        name.set(s,"小虎");
        age.set(s,25);

        System.out.println(name.get(s)+"  "+age.get(s));

    }
}
